import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/public/views/public_refresh.dart';
import '../../api/hireApi.dart';
import '../../models/hire_rent_model.dart';
import '../../views/hire_rent_item.dart';
import 'logic.dart';

class HireRentPage extends StatefulWidget {
  const HireRentPage({Key? key}) : super(key: key);

  @override
  State<HireRentPage> createState() => _HireRentPageState();
}

class _HireRentPageState extends State<HireRentPage> {
  final HireRentLogic logic = Get.put(HireRentLogic());
  int page = 1;

  @override
  Widget build(BuildContext context) {
    return HLRefresh<HireRentModel>(onRefresh: () async {
      page = 1;
      return await HireApi.rentList(page);
    }, onLoading: () async {
      page += 1;
      return await HireApi.rentList(page);
    }, snap: (itemModel, int index) {
      return HireRentItem(itemModel: itemModel);
    });
    ;
  }

  @override
  void dispose() {
    Get.delete<HireRentLogic>();
    super.dispose();
  }
}
